package com.miao.teacher.widget;

import android.app.Activity;
import android.content.Context;
import android.util.DisplayMetrics;

import com.miao.teacher.ui.R;
import com.slidingmenu.lib.SlidingMenu;

public class TSlidingMenu {
	private SlidingMenu menu;
	private Context context;

	public TSlidingMenu(Context c) {
		context = c;
		init();
	}

	private void init() {
		menu = new SlidingMenu(context);
		menu.setMode(SlidingMenu.RIGHT);
		menu.setTouchModeAbove(SlidingMenu.TOUCHMODE_MARGIN);
		menu.setShadowWidthRes(R.dimen.slidingmenu_shadowWidth);
		menu.setShadowDrawable(R.drawable.shadow);
		menu.setBehindOffsetRes(R.dimen.slidingmenu_behindOffset);
		menu.setFadeDegree(0.35f);
		menu.setBehindWidth((int)(getXPx()*0.7));
		menu.attachToActivity((Activity)context, SlidingMenu.SLIDING_CONTENT);
		menu.setMenu(R.layout.frame_menu);
	}
	public void setSelectIndex(int index)
	{
		
	}
	
	protected int getXPx() {
		DisplayMetrics dm = new DisplayMetrics();
		((Activity)context).getWindowManager().getDefaultDisplay().getMetrics(dm);
		dm = context.getApplicationContext().getResources().getDisplayMetrics();
		return dm.widthPixels;
	}
	public SlidingMenu getMenu()
	{
		return menu;
	}
}
